Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
PUBLISH and SUBSCRIBE statements
When you have multiple procedures running in a session, you might want them to communicate with each other without being strictly bound to each other. In other words, one procedure might want to send a message to other procedures that are interested in receiving that message without knowing or caring just how many such procedures there are, what their procedure handles are, or what they intend to do with the information. Likewise, a procedure might want to post an interest in receiving a message on a subject without necessarily knowing or caring where the message comes from.
Progress supports
PUBLISHandSUBSCRIBEkeywords for this purpose. One procedure can publish a named event when something of interest happens and other procedures running in the same session can subscribe to that same event name, either in a particular procedure handle or anywhere in the session. When the event occurs, an internal procedure in each subscriber runs. If there are no subscribers, then nothing happens and no error results. If there are many subscribers, they all get the message. In effect, aPUBLISHstatement amounts to Progress executing this pseudo-code:
The order in which multiple subscribers receive an event is undefined.
Just as with any procedure call, a
PUBLISHstatement can include one or more parameters. These are normallyINPUTparameters, although under some circumstances other parameter modes can be useful.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |